package com.hzw.jdbc.statementTest;

import com.hzw.utils.JdbcUtil;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class SelectDemo01 {
    public static void main(String[] args) throws SQLException {
        Connection connection = JdbcUtil.getConnection();
        Statement statement = connection.createStatement();
        String sql="SELECT `id`,`username`,`password` FROM `user` order by `id`";
        ResultSet resultSet = statement.executeQuery(sql);
        while (resultSet.next()){
            System.out.println("id=" + resultSet.getString("id")
                    +" username=" + resultSet.getString("username")
                    +" password=" + resultSet.getString("password"));
        }
        JdbcUtil.release(connection,statement,resultSet);
    }
}
